﻿/**
 * Created by Administrator on 2017/8/28.
 */
define(['ShowContact'],function (ShowContact) {
    var ContactInfo = {
        name: 'contact-info',
        template: ''
        + '<div class="cnntItem clearfix noEdit">'
        + '    <div class="connection_girl" v-if="relation.Gender===1"></div>'
        + '    <div class="connection_boy" v-else></div>'
        + '    <div class="right-conent">'
        + '        <div class="right-connection-top">'
        + '            <span>姓名：<i>{{relation.NameText}}</i></span>'
        + '            <span>关系：<i>{{relation.RelationText}}</i></span>'
        + '        </div>'
        + '        <div class="right-connection-btm">'
        + '            <show-contact v-bind:contact-value-list="relation.Mobile" v-bind:relation-id="relation.CustomerId"></show-contact>'
        + '            <div class="cnnt_right">'
        + '                <span class="cnnt_zj">座机：<i>{{relation.Telephone.ContactValue}}</i><em></em></span>'
        + '                <span class="cnnt_wx">微信：<i>{{relation.WeChat.ContactValue}}</i><em></em></span>'
        + '                <span class="cnnt_qq">QQ：<i>{{relation.QQ.ContactValue}}</i><em></em></span>'
        + '            </div>'
        + '        </div>'
        + '    </div>'
        + '    <div class="delectBtn deleteRelationBtn" v-if="relation.RelationText!=\'本人\' && poolType!=\'RecyclePool\'" v-on:click="deleteRelation=true"></div>'
        + '<!-- Confirm弹框begin-->'
        + '<Modal class="addCustomerConfirm" v-model="deleteRelation"'
        + '       width="360"'
        + '       title="删除确认"'
        + '       closable="false"'
        + '       mask-closable="false"'
        + '       v-on:on-ok="confirmDelete"'
        + '       class-name="addPublicWrap  vertical-center-modal">'
        + '    <div class="modal-content">'
        + '        <ul class="pri-ul">'
        + '            <h3 class="warning">确定要删除该亲友及其联系方式？</h3>'
        + '        </ul>'
        + '    </div>'
        + '</Modal>'
        + '<!--Confirm弹框end-->'
        + '</div>',
        props: {
            poolType:String,
            relation: {
                type: Object,
                default: function () {
                    return {
                        NameText: "",
                        RelationText: "",
                        Gender: 0,
                        Mobile: [{
                            Type: 0,
                            TypeText:"手机",
                            IsUsually: true,
                            ContactValue: "",
                        }],
                        Telephone: {
                            ContactValue: ""
                        },
                        WeChat: {
                            ContactValue: ""
                        },
                        QQ: {
                            ContactValue: ""
                        }
                    };
                }
            },
        },
        data: function () {
            return {
                deleteRelation: false,
            };
        },
        mounted: function () {
            var thisInfo = this;
            ////监听changeContactUsually
            //global.bus.$on("changeContactUsually", function (data) {
            //    //触发changeRelationContactUsually
            //    global.bus.$emit("changeRelationContactUsually", {
            //        Relation: thisInfo.Relation,
            //        Name: thisInfo.Name,
            //        Type: data.Type,
            //        ContactValue: data.ContactValue,
            //    });
            //});
        },
        components: {
            ShowContact: ShowContact,
        },
        methods: {
            confirmDelete: function () {
                window.bus.$emit("deleteRelation", this.relation.CustomerId);
            },
        },
        computed: {
        }
    };
    return  ContactInfo;
});

